import QtQuick

Rectangle {
    signal wPositionChanged(x:int,y:int)
    MouseArea {
        propagateComposedEvents: true
        preventStealing: false
        anchors.fill: parent
        acceptedButtons: Qt.LeftButton
        property point clickPos: '0,0'

        onPositionChanged: function (mouse) {
            var delta = Qt.point(mouse.x - clickPos.x,
                                 mouse.y - clickPos.y)
            wPositionChanged(delta.x,delta.y)
        }

        onPressed: (mouse) => {
           if(mouse.x < 10 || mouse.x > width-10 ||
              mouse.y < 10 || mouse.y > height-10) {
                mouse.accepted = false
           } else {
               clickPos = Qt.point(mouse.x, mouse.y)
               mouse.accepted = true  // 允许穿透到上层
           }
        }
    }
}
